%% -*- mode: erlang -*-
%% Base dispatch rules for zotonic
[
    %% The id controller redirects depending on the accept header sent by the user agent.
    {id, ["id", id], controller_id, []},

    %% CSS, Javascript and images from the "lib" module folders. Possibly more than one file combined in a single request.
    {lib, ["lib",'*'], controller_file, [ {root,[lib]}]},

    %% Automatically minified CSS, Javascript from the "lib-min" module folders. %% The files are minified with the css and js minifier implementations in
    %% git@github.com:zotonic/z_stdlib.git
    {lib_min, ["lib-min",'*'], controller_file, [ {root,[lib]}, {minify, true} ]},

    %% No-cache variants let the browser cache the file max 1 second, useful for files
    %% that change frequently.
    {lib_nocache, ["lib-nocache",'*'], controller_file, [ {root,[lib]}, {max_age, 1} ]},
    {lib_min_nocache, ["lib-min-nocache",'*'], controller_file, [ {root,[lib]}, {max_age, 1}, {minify, true} ]},

    {image, ["image",'*'], controller_file, []},

    {media_attachment, ["media","attachment","id",id], controller_file_id, [ {dispatch, media_attachment}]},
    {media_attachment, ["media","attachment",'*'], controller_file, [ {content_disposition, attachment}]},

    {media_inline, ["media","inline","id",id], controller_file_id, [ {dispatch, media_inline}]},
    {media_inline, ["media","inline",'*'], controller_file, [ {content_disposition, inline}]},

    %% API access
    {api, ["api", '*'], controller_api, []},

    % Used for redirects by controller_id - change this if another model should be used.
    {api_rsc_export, [ "api", "model", "rsc_export", "get", id ], controller_api, []},

    %% Serves the favicon.ico from "lib/images/favicon.ico" in the modules.
    {favicon, ["favicon.ico"], controller_file, [ {path, "images/favicon.ico"}, {root,[lib]}, {content_disposition, inline}]},

    %% Provide information about the site. Needed to install site on home-screens
    {manifest_json, [ "manifest.json" ], controller_file, [ {root, [lib]}, {max_age, 1}, {path, "misc/manifest.json"} ]},

    %% Log client side javascript event. This is ignored by default `mod_logging` overrides this when enabled.
    {jslog, ["log-client-event"], controller_nocontent, []},

    %% robots.txt - simple allow all file
    {robots_txt, ["robots.txt"], controller_file, [
            {path, "misc/robots.txt"}, {root,[lib]}, {content_disposition, inline}
        ]},

    %% security.txt - serve a template with the security settings - https://securitytxt.org
    {security_txt, [".well-known", "security.txt"], controller_template, [
            {template, "security.txt.tpl"}, {content_type, "text/plain"}, {anonymous, true}
        ]},

    %% Ping/pong
    {zotonic_ping, [".zotonic", "ping"], controller_ping, []}
].
